<template>
<div>
  <template>
    <el-table
      :data="saleDocData"
      style="width: 100%">
      <el-table-column
      prop="id" label="id">
      </el-table-column>
      <el-table-column
        prop="bookTitle"
        label="书名">
      </el-table-column>
      <el-table-column
        prop="isbn"
        label="isbn码"
      >
      </el-table-column>
      <el-table-column
        prop="buyerName"
        label="借阅人">
      </el-table-column>
      <el-table-column
        prop="salerName"
        label="借书人">
      </el-table-column>
      <el-table-column
        prop="price"
        label="价格">
      </el-table-column>
      <el-table-column prop="num" label="数量"/>
      <el-table-column prop="amount" label="总价"/>
      <el-table-column prop="type" label="状态"/>
      <el-table-column label="操作">
        <template slot-scope="saleDocData">
          <el-button @click="deleteDoc(saleDocData.row.id)" type="danger">删除</el-button>
<!--          <el-button @click="updataCa2(saleDocData.row)" type="info">修改</el-button>-->
        </template>
      </el-table-column>
    </el-table>
  </template>
</div>
</template>

<script>
import {ApiService} from "@/api/apiService";

export default {
  data() {
    return {
      saleDocData: []
    }
  },
  mounted() {
    this.getSaleDocMessage()
  },
  methods:{
    //获取订单数据
    getSaleDocMessage(){
      console.log("获取订单数据")
      const  getSaleDoc = new ApiService("/sale/SaleDoc/getMessage")
      getSaleDoc.getParams().then(
        res=>{
          console.log(res.data)
          this.saleDocData = res.data;
        }

      )
    },
    //删除订单
    deleteDoc(id) {
      const api = new ApiService("/saleDoc/delete")
      api.getParams({
        id:id,
      }).then(res=> {
        if(res.data.code) {
          this.$notify({
            message:"删除成功"
          })
          this.getSaleDocMessage()
        }

      })
    },
  }
}
</script>
<style scoped>

</style>
